From 3a45003bfb8eb7fc1fa1cdc2d565651a2c613af6 Mon Sep 17 00:00:00 2001 From: Nat Gist <25966140+ngist@users.noreply.github.com> Date: Fri, 22 Aug 2025 20:44:02 +0000 Subject: [PATCH] luci-app-statistics: Adds ability to configure encrypted connections in the MQTT package Updates mqtt.js to add user interface to configure a path to a CA Cert file to be used by MQTT to verify the servers certificate, and adds a setting to configure the TLS verison to be used for the conneciton. Also updates stat-genconfig to then copy these settings into the generated collectd.conf Signed-off-by: Nat Gist --- .../resources/view/statistics/plugins/mqtt.js | 13 +++++++++++++ .../root/usr/libexec/stat-genconfig | 2 ++ 2 files changed, 15 insertions(+) diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js index 602a453c0b..73de2f5cf6 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js @@ -68,6 +68,19 @@ return baseclass.extend({ o.value('false', _('False')); o.modalonly = true; o.optional = true; + + o = ss.option(form.ListValue, 'TLSProtocol', _('TLSProtocol')); + o.depends('blocktype', 'Publish'); + o.value('tlsv1.2', _('TLS 1.2')); + o.value('tlsv1.3', _('TLS 1.3')); + o.modalonly = true; + o.optional = true; + + o = ss.option(form.Value, 'CACert', _('CACert')); + o.depends({'TLSProtocol': 'tls', '!contains': true }); + o.optional = true; + o.modalonly = true; + o.default = '/etc/ssl/certs/ca-certificates.crt'; o = ss.option(form.ListValue, 'CleanSession', _('CleanSession')); o.depends('blocktype', 'Subscribe'); diff --git a/applications/luci-app-statistics/root/usr/libexec/stat-genconfig b/applications/luci-app-statistics/root/usr/libexec/stat-genconfig index 0d6bd6704f..68c9b09e88 100755 --- a/applications/luci-app-statistics/root/usr/libexec/stat-genconfig +++ b/applications/luci-app-statistics/root/usr/libexec/stat-genconfig @@ -260,6 +260,8 @@ function config_mqtt(c) { str += s['StoreRates'] ? `\t\tRetain ${s.StoreRates}\n` : ''; str += s['CleanSession'] ? `\t\tRetain ${s.CleanSession}\n` : ''; str += s['Topic'] ? `\t\tTopic "${s.Topic}"\n` : ''; + str += s['CACert'] ? `\t\tCACert "${s.CACert}"\n` : ''; + str += s['TLSProtocol'] ? `\t\tTLSProtocol "${s.TLSProtocol}"\n` : ''; str += isPublish ? `\t\n` : `\t\n`; } -- 2.30.2